<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = ["张三", "李四", "王五"];
      var str = "";
      arr.forEach(function (item) {
        str += item + "&";
      });
      console.log(str);
      console.log(str.substr(0, str.length - 1));
      //或者直接给arr数组 加join
      //   console.log(arr.join("&"));

      var obj = {
        name: "张三",
        age: 20,
      };
      for (var i in obj) {
        // console.log(obj.hasOwnProperty(i)); //判断 对象的某个属性是否是自身属性 如果是 返回true 否则返回false
        console.log(i);
        if (obj.hasOwnProperty(i)) {
          console.log(i);
        }
      }
    </script>
  </body>
</html>
